//PARADIME INTERPRETER
//
//LICENSED FREELY UNDER MIT.
//CREATED FOR FREE USE.
#ifndef EXPLOR_INTERPRETER
#define EXPLOR_INTERPRETER

//INTERPRETER STATES
enum{
	READY_NOINPUT,
	EXEC_READY,
	GENERAL_FAULT,
	INIT_FAULT
};

//Modes for error handling
enum{
	INTERPRETER_HALT,		//Stop the interpreter/context.
	PROCESS_ERROR_DIE,		//Error out process with an autoit-like error
	SOFTWARE_TRAP,			//Fire the scripts error handler
};


#include "Codeblock_Datatypes.h"
#include "errorcodes.h"

class Interpreter
{
public:
	Interpreter(char* name,void** ParentDomain);
	int Set_Raw_CodeFILE(char* filename);
	int Start(void);
	void* Domain; //Have to use a void* as otherwise we get circular dependicies.
	void Dump_Variables(void);

	//Builtin name->function pointer associative array
	std::map<std::string,int (*)(token* ,std::vector<token>*,Interpreter* CodeOwner)> BuiltinTable;
private:
	int State; //See ENUM above.
	int ErrorHandlingMode; //Allows you to control wether to trap error, die, or ignore.
	char name[30];
	std::vector<token> tokenlist;
	std::vector<Functionentry> Functions;

	int Error(int errorcode, char* message);
	int LoadParse_IndexFuncs(void);
};

#endif